package com.example.springlearning.to;

/**
 * @author luo
 * @description
 * @since 2022/8/8 17:33
 */
public class SubtractStockResultProxy implements SubtractStockResult {

    private final SubtractStockResult subtractStockResult;
    private final OrderItemTo orderItemTo;

    public SubtractStockResultProxy(SubtractStockResult subtractStockResult, OrderItemTo orderItemTo) {
        this.subtractStockResult = subtractStockResult;
        this.orderItemTo = orderItemTo;
    }

    @Override
    public boolean getSubtractStockResult() throws InterruptedException {
        boolean subtractStockResult = this.subtractStockResult.getSubtractStockResult();
        if (subtractStockResult) {
//            整个批量扣库存的订单都成功了
            return true;
        }
//        查看单个扣库存的订单是否成功
        return orderItemTo.getSubtractStockResult();
    }
}
